package  
{
	import net.flashpunk.Entity;
	import net.flashpunk.FP;
	import net.flashpunk.graphics.Image;
	import net.flashpunk.graphics.Spritemap;
	import net.flashpunk.Sfx;

	
	/**
	 * ...
	 * @author Donatello
	 */
	
	public class Batman extends Player
	{
		[Embed(source = "img/batmansheet.png")]
		private const PLAYER_ANIM:Class;
		public var playerAnim:Spritemap;
		
		[Embed(source = "snd/i_am_batman.mp3")]
		private const BATMAN_MP3:Class;
		private var batmanSfx:Sfx;
		
		[Embed(source = "snd/secret.mp3")]
		private const SECRET_MP3:Class;
		private var secretSfx:Sfx;
		
		public function Batman(px:Number=305,py:Number=500) 
		{
			
			playerAnim = new Spritemap(PLAYER_ANIM, 34, 48);
			
			playerAnim.add("idle", [1], 10, true);
			playerAnim.add("walking", [3,4,5], 10, true);
			playerAnim.add("jump", [0], 10, false);
			playerAnim.add("power", [6, 7], 10, false);
		
			x = px;
			y = py;
			
			this.graphic = playerAnim;
				
			setHitbox(34,37);
						
			playerAnim.play("idle");
		
			jumpPower = 15;
			
			batmanSfx = new Sfx(BATMAN_MP3);
			secretSfx = new Sfx(SECRET_MP3);
					
			batmanSfx.play();
		
		}
		
		override public function actualizar():void {
			
			playerAnim.flipped = flipped;
					
			if (state == "power")
			{
				var aux:int=-1;
				if (!flipped)
					aux = 1;
				
				var e:Entity;
					
				e = collide("WallBeakable", x + aux, y);
				if (e)
				{
					//Romper
					secretSfx.play();
					FP.world.remove(e);
				}
				
				
				
				if(playerAnim.complete)
					state = "idle";
			}
			
			
			playerAnim.play(state);
			
			
		}
		
	}

}